home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXsource / beebe / c / dvieps < prev    next >
Encoding:
Text File  |  1991-02-19  |  19.2 KB  |  727 lines

  1. /* -*-C-*- dvieps.c */
  2. /*-->dvieps*/
  3. /**********************************************************************/
  4. /******************************* dvieps *******************************/
  5. /**********************************************************************/
  6.  
  7. /***********************************************************************
  8. DVIEPS was  developed from  one  of the  dot-matrix printer  drivers  by
  9. Marcus  Moehrmann  (EMAIL:   marcus%fkihh@unido.uucp).   The   following
  10. remarks are his.
  11.  
  12. This is an implementation for  Epson and compatible printers.   Printers
  13. with 9 needles are supported; those with 24 are not. I hope that I  have
  14. only used the ESC/P-Standard.  The only documentation I  have had was  a
  15. description for the NEC Pinwriter P6/P7,  but our printer is a  Logitec,
  16. which I used for testing.
  17.  
  18. There is a difference in paper feeding, because the P6/P7-handbook  says
  19. that
  20.  
  21.     <ESC> J (n)
  22.  
  23. performs n/180 inch paper feeding,  but our printer performs n/216  inch
  24. paper feeding, which I think is the standard, so I have used this in the
  25. driver.
  26.  
  27. For horizontal resolution I have used the Esc-sequences
  28.  
  29.     <ESC> * (m) (n1) (n2)        [m = 0, 1, 2, 3]
  30.  
  31. instead of
  32.  
  33.     <ESC> (x) (n1) (n2)        [x = 'K', 'L', 'Y', 'Z']
  34.  
  35. If this  will  not work  on  your  printer, change  the  definitions  of
  36. 'EPSON_BIT_IMAGE' and 'EPSON_MICRO_STEP'  and the variable  'resolution'
  37. in procedure 'outline'.
  38.  
  39. Be careful with the reset command
  40.  
  41.     <ESC> @
  42.  
  43. I have done this before any printing, and then after about 1.5 pages the
  44. printer stopped. The same works quite well on a second printer.
  45.  
  46. Specialities: There is a switch '-t' for twice-a-line printing, that is,
  47. print one  line in  1/120  inch horizontal  spacing, return  print  head
  48. without paper feeding,  perform a  1/240 inch  step and  then print  the
  49. second line with 1/120 inch spacing.
  50.  
  51. ***********************************************************************/
  52.  
  53. #include "dvihead.h"
  54.  
  55. /**********************************************************************/
  56. /************************  Device Definitions  ************************/
  57. /**********************************************************************/
  58.  
  59. /* All output-device-specific definitions go here.  This section must
  60. be changed when modifying a dvi driver for use on a new device */
  61.  
  62. #undef EPSON
  63. #define EPSON    1            /* conditional compilation flag */
  64.  
  65. #define VERSION_NO    "2.10 [experimental]"    /* DVI driver version number */
  66.  
  67. #undef HIRES
  68. #define  HIRES          1        /* 0 for 72-dpi version */
  69.  
  70. #if    HIRES
  71. #define  DEVICE_ID    "Epson 9-pin family 240/216-dpi matrix printer"
  72.                     /* this string is printed at runtime */
  73. #define OUTFILE_EXT    "eps"
  74.  
  75. #define  XDPI        240        /* horizontal dots/inch */
  76. #define  YDPI        216        /* vertical dots/inch */
  77.  
  78. #else /* NOT HIRES */
  79. #define  DEVICE_ID    "Epson 9-pin family 60/72-dpi matrix printer"
  80.                     /* this string is printed at runtime */
  81.  
  82. #define OUTFILE_EXT    "e72"
  83.  
  84. #define  XDPI        60        /* horizontal dots/inch */
  85. #define  YDPI        72        /* vertical dots/inch */
  86. #endif /* HIRES */
  87.  
  88. #define  BYTE_SIZE      8        /* output file byte size */
  89.  
  90. #undef STDRES
  91. #if    HIRES
  92. #define STDRES  1            /* 0 for low-resolution devices */
  93. #else /* NOT HIRES */
  94. #define STDRES  0            /* 0 for low-resolution devices */
  95. #endif /* HIRES */
  96.  
  97. #if    OS_PCDOS
  98. #define  XPSIZE        6        /* horizontal paper size in inches */
  99. #else /* NOT OS_PCDOS */
  100. #define  XPSIZE        8        /* horizontal paper size in inches */
  101. #endif /* OS_PCDOS */
  102.  
  103. #define  XSIZE        (((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\
  104.                 (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))
  105.                     /* number of horizontal dots; */
  106.                     /* MUST BE multiple of */
  107.                     /* 2*HOST_WORD_SIZE */
  108. #define  XWORDS        ((XSIZE + HOST_WORD_SIZE - 1)/HOST_WORD_SIZE)
  109.                     /* number of words in rows  */
  110.                     /* of bitmap array */
  111.  
  112. #if    OS_PCDOS
  113. #define  YPSIZE        8        /* vertical paper size in inches */
  114. #else /* NOT OS_PCDOS */
  115. #define  YPSIZE        11        /* vertical paper size in inches */
  116. #endif /* OS_PCDOS */
  117.  
  118. #define  YSIZE        (YDPI*YPSIZE)    /* number of vertical dots */
  119.  
  120. #if    HIRES
  121. INT16 paperfeeding;            /* outstanding 1/216 inch */
  122.                     /* form-feedings */
  123.  
  124. BOOLEAN twice_a_line = FALSE;        /* this is runtime option '-t' */
  125.                     /* print in 1/120-inch-mode, */
  126.                     /* 2nd line shifted 1/240 inch */
  127.  
  128.                     /* need single-arg outline() */
  129. BOOLEAN micro_step;            /* used in outline() */
  130. #define OUTLINE(v,flag) {micro_step = flag; outline(v);}
  131. #endif /* HIRES */
  132.  
  133. /* The printer bit map. */
  134.  
  135. #define XBIT XWORDS
  136. #define YBIT YSIZE
  137.  
  138. #if    (IBM_PC_LATTICE | IBM_PC_MICROSOFT | IBM_PC_WIZARD)
  139. #undef SEGMEM
  140. #define SEGMEM 1        /* ( ((long)XBIT * (long)YBIT) > 65536L ) */
  141. #endif /* (IBM_PC_LATTICE | IBM_PC_MICROSOFT | IBM_PC_WIZARD) */
  142.  
  143. #define EPSON_ADV_PAPER        "\033J%c"    /* advance paper n/216 inch */
  144. #define EPSON_BIT_IMAGE        "\033*%c%c%c"
  145. #define EPSON_MICRO_STEP    OUTF2("\033*\003\001%c%c",'\000','\000')
  146.  
  147. #include "bitmap.h"
  148.  
  149. #include "main.h"
  150. #include "abortrun.h"
  151. #include "actfact.h"
  152. #include "alldone.h"
  153. #include "chargf.h"
  154. #include "charpk.h"
  155. #include "charpxl.h"
  156. #include "clrbmap.h"
  157. #include "clrrow.h"
  158. #include "dbgopen.h"
  159.  
  160. /*-->devinit*/
  161. /**********************************************************************/
  162. /****************************** devinit *******************************/
  163. /**********************************************************************/
  164.  
  165. void
  166. devinit(argc, argv)        /* initialize device */
  167. int argc;
  168. char *argv[];
  169. {
  170.     (void)getbmap();
  171.     if (runlengthcode && !quiet)
  172.     {
  173.     (void)fprintf(stderr, "[Run-length encoding of output file]");
  174.     NEWLINE(stderr);
  175.     }
  176.  
  177. #if    HIRES
  178.     if (twice_a_line && !quiet)
  179.     {
  180.     (void)fprintf(stderr, "[Twice-a-line-printing for high resolution]");
  181.     NEWLINE(stderr);
  182.     }
  183. #endif /* HIRES */
  184.  
  185. }
  186.  
  187. /*-->devterm*/
  188. /**********************************************************************/
  189. /****************************** devterm *******************************/
  190. /**********************************************************************/
  191.  
  192. void
  193. devterm()            /* terminate device */
  194. {
  195. }
  196.  
  197. #include "dispchar.h"
  198. #include "dvifile.h"
  199. #include "dviinit.h"
  200. #include "dviterm.h"
  201. #include "f20open.h"
  202. #include "fatal.h"
  203. #include "fillrect.h"
  204. #include "findpost.h"
  205. #include "fixpos.h"
  206. #include "fontfile.h"
  207. #include "fontsub.h"
  208. #include "getbmap.h"
  209. #include "getbytes.h"
  210. #include "getfntdf.h"
  211. #include "getpgtab.h"
  212. #include "inch.h"
  213. #include "initglob.h"
  214. #include "loadchar.h"
  215.  
  216. /*-->makechar*/
  217. /**********************************************************************/
  218. /****************************** makechar ******************************/
  219. /**********************************************************************/
  220.  
  221. char
  222. makechar(p, mask)
  223. register UNSIGN32 *p[];
  224. register UNSIGN32 mask;
  225. {
  226.     register char c;
  227.  
  228. #if    SEGMEM
  229. #define Q(n) p[n]        /* use precomputed pointers */
  230. #else /* NOT SEGMEM */
  231. #define Q(n) (p[0] - (n)*XBIT)    /* compute pointers on the fly */
  232. #endif /* SEGMEM */
  233.  
  234.     c = '\000';                /* MSB controls top needle */
  235.  
  236. #if    HIRES
  237.     if (*Q(0) & mask)
  238.     c |= '\200';
  239.     if (*Q(3) & mask)
  240.     c |= '\100';
  241.     if (*Q(6) & mask)
  242.     c |= '\040';
  243.     if (*Q(9) & mask)
  244.     c |= '\020';
  245.     if (*Q(12) & mask)
  246.     c |= '\010';
  247.     if (*Q(15) & mask)
  248.     c |= '\004';
  249.     if (*Q(18) & mask)
  250.     c |= '\002';
  251.     if (*Q(21) & mask)
  252.     c |= '\001';
  253. #else /* NOT HIRES */
  254.     if (*Q(0) & mask)
  255.     c |= '\200';
  256.     if (*Q(1) & mask)
  257.     c |= '\100';
  258.     if (*Q(2) & mask)
  259.     c |= '\040';
  260.     if (*Q(3) & mask)
  261.     c |= '\020';
  262.     if (*Q(4) & mask)
  263.     c |= '\010';
  264.     if (*Q(5) & mask)
  265.     c |= '\004';
  266.     if (*Q(6) & mask)
  267.     c |= '\002';
  268.     if (*Q(7) & mask)
  269.     c |= '\001';
  270. #endif /* HIRES */
  271.  
  272.     return (c);
  273. }
  274.  
  275. #include "movedown.h"
  276. #include "moveover.h"
  277. #include "moveto.h"
  278. #include "nosignex.h"
  279. #include "openfont.h"
  280. #include "option.h"
  281.  
  282. #if    HIRES
  283. /*-->outpaperfeed*/
  284. /**********************************************************************/
  285. /*************************** outpaperfeed *****************************/
  286. /**********************************************************************/
  287.  
  288. #ifdef __STDC__
  289. void outpaperfeed(INT16 count)
  290. #else
  291. void
  292. outpaperfeed(count)        /* accumulate 1/216 inch paperfeedings */
  293. INT16 count;            /* and write them out if count == 0 */
  294. #endif
  295. {
  296.  
  297.     register INT16 k;
  298.  
  299.     if (count)
  300.     paperfeeding += count;
  301.     else
  302.     {
  303.     for (k = paperfeeding / 255; k; --k)
  304.         OUTF(EPSON_ADV_PAPER, 255);
  305.     if ((k = paperfeeding % 255) > 0)
  306.         OUTF(EPSON_ADV_PAPER, k);
  307.     paperfeeding = 0;
  308.     }
  309. }
  310. #endif /* HIRES */
  311.  
  312. /*-->outline*/
  313. /**********************************************************************/
  314. /****************************** outline *******************************/
  315. /**********************************************************************/
  316.  
  317. void
  318. outline(pline)
  319. char *pline;
  320. {
  321.     register char* a;
  322.     register char* b;
  323.     register char* c;
  324.     register INT16 left;
  325.     INT16 len;
  326.     INT16 linelength;
  327.     char resolution;
  328.     BYTE spacing;
  329.     BYTE space_width;
  330.  
  331. #if    HIRES
  332.     if (twice_a_line)            /* step 1/240 inch forward */
  333.     {
  334.     resolution = '\001';        /* 1/120 */
  335.     space_width = 12;        /* 12/120 */
  336.     linelength = XSIZE / 2;
  337.     }
  338.     else
  339.     {
  340.     resolution = '\003';        /* 1/240 */
  341.     space_width = 24;        /* 24/240 */
  342.     linelength = XSIZE;
  343.     }
  344. #else /* NOT HIRES */
  345.     resolution = '\000';        /* 1/60 */
  346.     space_width = 6;            /* 6/60 */
  347.     linelength = XSIZE;
  348. #endif /* HIRES */
  349.  
  350.     for ((left = linelength, c = pline + linelength - 1);
  351.      (*c == '\000') && (left > 0);
  352.      (--left, --c))            /* trim white space */
  353.     ;
  354.  
  355.     if (left == 0)
  356.     return;        /* NEWLINE() is not needed for any paperfeeding */
  357.  
  358. #if    HIRES
  359.     (void)outpaperfeed(0);        /* print accumulated paperfeedings */
  360. #endif /* HIRES */
  361.  
  362.     /*******************************************************************
  363.     We search for runs as follows.  "b" marks the beginning of unwritten
  364.     data, and "a" anchors the beginning of a run which continues to just
  365.     before "c".   The  run length  is  "c"-"a".  Only  runs  longer than
  366.     "space_width" are taken, because we print spaces in text mode.  This
  367.     implies that the run only consists of '\000' characters.
  368.  
  369.     If a long  enough run  is found,  then the  string "b"  .. "a"-1  is
  370.     output since its length is now  known, followed by the run  encoding
  371.     for the character at "a".  Then "a" and "b" are advanced to "c", and
  372.     the scan continues.
  373.  
  374.     If the  run  beginning at  "a"  is too  short,  then "a"  is  simply
  375.     advanced.
  376.  
  377.     Since the  character strings  take on  all values  on 0  .. 255,  we
  378.     cannot store a termination marker, but must instead keep a  counter,
  379.     "left", which is  decremented to  0 when the  end of  the string  is
  380.     reached.
  381.  
  382.     ?????????????0000000000000000????????????????????
  383.     ^            ^               ^
  384.     |            |               |
  385.     b            a               c
  386.  
  387.                  <-----run------>
  388.  
  389.  
  390.     We cannot use fprintf %s because 0 bytes terminate string, so we are
  391.     using putc for writing the line.
  392.     *******************************************************************/
  393.  
  394.     if (runlengthcode && (left >= space_width))
  395.     {
  396.     for (a = b = pline; (left > 0); --left)
  397.     {
  398.         for (c = a; (*a == *++c) && (*a == '\000') && left; --left)
  399.         ;            /* advance over run */
  400.         len = (INT16) (c - a);    /* "c" points past run */
  401.  
  402.         if (len >= space_width)    /* output long run */
  403.         {
  404.         if (a > b)        /* output previous string */
  405.         {
  406. #if    HIRES
  407.             if (micro_step)
  408.             {
  409.             EPSON_MICRO_STEP;
  410.             micro_step = FALSE;
  411.             }
  412. #endif /* HIRES */
  413.             OUTF3(EPSON_BIT_IMAGE, resolution, ((int) (a - b)) % 256,
  414.               ((int) (a - b)) / 256);
  415.             for (; b < a; b++)
  416.             OUTC(*b);
  417.         }
  418.  
  419.         c -= len % space_width;    /* shorten run */
  420.         left += len % space_width;
  421.  
  422.         for (spacing = (BYTE)(len / space_width); spacing; --spacing)
  423.             OUTC(' ');        /* output run */
  424.  
  425.         a = b = c;
  426.         }
  427.         else            /* ignore short run */
  428.         {
  429.         ++a;
  430.         left += len - 1;
  431.         }
  432.     }                /* end for() loop */
  433.  
  434.     if (a > b)            /* output remaining string */
  435.     {
  436. #if    HIRES
  437.         if (micro_step)
  438.         {
  439.         EPSON_MICRO_STEP;
  440.         micro_step = FALSE;
  441.         }
  442. #endif /* HIRES */
  443.         OUTF3(EPSON_BIT_IMAGE,resolution,((int) (a - b)) % 256,
  444.           ((int) (a - b)) / 256);
  445.         for (; b < a; b++)
  446.         OUTC(*b);
  447.     }
  448.     }
  449.     else                /* no runlength coding */
  450.     if (left > 0)
  451.     {
  452. #if    HIRES
  453.     if (micro_step)
  454.     {
  455.         EPSON_MICRO_STEP;
  456.         micro_step = FALSE;
  457.     }
  458. #endif /* HIRES */
  459.     OUTF3(EPSON_BIT_IMAGE,resolution,left % 256,left / 256);
  460.     for (c = pline; left; --left, c++)
  461.         OUTC(*c);
  462.     }
  463.     NEWLINE(plotfp);
  464. }
  465.  
  466. #include "outrow.h"
  467.  
  468. /*-->prtbmap*/
  469. /**********************************************************************/
  470. /****************************** prtbmap *******************************/
  471. /**********************************************************************/
  472.  
  473. void
  474. prtbmap()
  475. {
  476.     register BYTE *c;            /* pointer into v8[][] and v8t[][][] */
  477.     UNSIGN32 *p;            /* pointer into bitmap[][] */
  478.  
  479. #if    SEGMEM
  480. #else /* NOT SEGMEM */
  481.     UNSIGN32 *ptmp;            /* pointer into bitmap[][] */
  482. #endif /* SEGMEM */
  483.  
  484.     register UNSIGN32 mask;        /* mask for single bit selection */
  485.     register INT16 k;
  486.     INT16 i;
  487.     INT16 j;
  488.     INT16 ybottom;
  489.     INT16 ytop;
  490.  
  491. #if    HIRES
  492.     BYTE v8[3][XSIZE];            /* vertical 8-bit raster encodings */
  493.     BYTE v8t[3][2][XSIZE / 2];        /* vertical 8-bit raster encodings */
  494.                     /* (twice-a-line) */
  495.     INT16 second = 0;            /* address second byte if not zero */
  496.  
  497. #undef Q
  498. #if    SEGMEM
  499.     UNSIGN32 *q[24];            /* pointers to 24 raster lines */
  500. #define Q(n) q[n]            /* use precomputed pointers */
  501. #else /* NOT SEGMEM */
  502. #define Q(n) (p - (n)*XBIT)        /* compute pointers on the fly */
  503. #endif /* SEGMEM */
  504.  
  505.     (void)clearerr(plotfp);
  506.  
  507.     ytop = YBIT - 1;
  508.  
  509.     k = -1;                /* find bottom non-zero raster */
  510.     for (j = 0; (j < ytop) && (k < 0); ++j)    /* loop over raster lines */
  511.     {
  512.  
  513. #if    IBM_PC_MICROSOFT
  514.     for (k = XBIT - 1; ((k >= 0) && (*BITMAP(j, k) == 0)); --k)
  515.         ;                /* trim white space */
  516.  
  517. #else /* NOT IBM_PC_MICROSOFT */
  518.     p = BITMAP(j, XBIT - 1);
  519.     for (k = XBIT - 1; ((k >= 0) && (*p == 0)); --k)
  520.         --p;            /* trim white space */
  521. #endif /* IBM_PC_MICROSOFT */
  522.  
  523.     }
  524.     ybottom = (j / 24) * 24 + 23;
  525.  
  526.     paperfeeding = 0;            /* for outpaperfeed() */
  527.     OUTF("\0333%c", 0);            /* no paperfeeding */
  528.  
  529.     for (j = ytop; (j >= ybottom); j -= 24)    /* loop over raster lines */
  530.     {                    /* in groups of 24 */
  531.  
  532. #if    SEGMEM
  533. #else /* NOT SEGMEM */
  534.     p = BITMAP(j, 0);        /* the j-th raster line */
  535. #endif /* SEGMEM */
  536.  
  537.     if (twice_a_line)
  538.         c = &v8t[0][0][0];        /* vertical 8-bit encodings */
  539.     else
  540.         c = &v8[0][0];        /* vertical 8-bit encodings */
  541.  
  542.     for (i = 0; i < XBIT; (++p, ++i))    /* loop over raster words */
  543.     {
  544.         /* PCC-20 compiled (1 << (HOST_WORD_SIZE-1)) to 0, so do it the
  545.            hard way, arghh... */
  546.         mask = 1;
  547.         mask <<= (HOST_WORD_SIZE - 1);    /* to select leftmost bit */
  548.  
  549. #if    SEGMEM
  550.         for (k = 0; k < 24; ++k)    /* compute pointers to 24 rasters */
  551.         q[k] = BITMAP(j - k, i);
  552. #endif /* SEGMEM */
  553.  
  554.         for (k = 0; k < HOST_WORD_SIZE; (++k)) /* loop over word bits */
  555.         {
  556.         /* examine bits in 24 adjacent rows and build two 8-bit */
  557.         /* character values, the first with rows n,n+3,...,n+21, */
  558.         /* the second with rows n+1,n+4,...,n+22, the third with */
  559.         /* rows n+2,n+5,...,n+23. The 2nd and 3rd characters are */
  560.         /* then printed with 1 dot vertical spacing. */
  561.  
  562.         /* if twice_a_line is TRUE, the bytes will be written */
  563.         /* alternating in v8t[x][0][y] and v8t[x][1][y] */
  564.  
  565.         if (twice_a_line)
  566.             second = (k % 2) * XSIZE / 2;
  567.  
  568. #if    SEGMEM
  569.         *(c + second) = (BYTE) makechar(&q[0], mask);
  570.         *(c + XSIZE + second) = (BYTE) makechar(&q[1], mask);
  571.         *(c + 2 * XSIZE + second) = (BYTE) makechar(&q[2], mask);
  572. #else /* NOT SEGMEM */
  573.         *(c + second) = (BYTE) makechar(&p, mask);
  574.         ptmp = p - XBIT;
  575.         *(c + XSIZE + second) = (BYTE) makechar(&ptmp, mask);
  576.         ptmp = p - 2 * XBIT;
  577.         *(c + 2 * XSIZE + second) = (BYTE) makechar(&ptmp, mask);
  578. #endif /* SEGMEM */
  579.  
  580.         if (twice_a_line)
  581.         {
  582.             if (second)
  583.             c++;        /* increment after second byte */
  584.         }
  585.         else
  586.             c++;
  587.  
  588.         mask >>= 1;        /* move masking bit right 1 position */
  589.         }                /* end loop over k */
  590.     }                /* end loop over i */
  591.  
  592.     if (twice_a_line)
  593.     {
  594.         OUTLINE((char *) &v8t[0][0][0], FALSE);
  595.         OUTLINE((char *) &v8t[0][1][0], TRUE);
  596.         (void)outpaperfeed(1);
  597.         OUTLINE((char *) &v8t[1][0][0], FALSE);
  598.         OUTLINE((char *) &v8t[1][1][0], TRUE);
  599.         (void)outpaperfeed(1);
  600.         OUTLINE((char *) &v8t[2][0][0], FALSE);
  601.         OUTLINE((char *) &v8t[2][1][0], TRUE);
  602.         (void)outpaperfeed(22);
  603.     }
  604.     else
  605.     {
  606.         OUTLINE((char *) &v8[0][0], FALSE);
  607.         (void)outpaperfeed(1);
  608.         OUTLINE((char *) &v8[1][0], FALSE);
  609.         (void)outpaperfeed(1);
  610.         OUTLINE((char *) &v8[2][0], FALSE);
  611.         (void)outpaperfeed(22);
  612.     }
  613.  
  614.     }                    /* end loop over j */
  615.  
  616.     OUTS("\0332");            /* ESC 2 = normal paperfeeding */
  617.     OUTC('\f');                /* eject page with FF */
  618.  
  619.     (void)fflush(plotfp);
  620.     if (DISKFULL(plotfp))
  621.     (void)fatal("prtbmap(): Output error -- disk storage probably full");
  622. }
  623.  
  624. #else /* NOT HIRES */
  625.     BYTE v8[XSIZE + 2];            /* vertical 8-bit raster encodings */
  626.  
  627. #undef Q
  628. #if    SEGMEM
  629.     UNSIGN32 *q[8];            /* pointers to 8 raster lines */
  630. #define Q(n) q[n]            /* use precomputed pointers */
  631. #else /* NOT SEGMEM */
  632. #define Q(n) (p - (n)*XBIT)        /* compute pointers on the fly */
  633. #endif /* SEGMEM */
  634.  
  635.     ytop = YBIT - 1;
  636.  
  637.     k = -1;                /* find bottom non-zero raster */
  638.     for (j = 0; (j < ytop) && (k < 0); ++j)    /* loop over raster lines */
  639.     {
  640.  
  641. #if    IBM_PC_MICROSOFT
  642.     for (k = XBIT - 1; ((k >= 0) && (*BITMAP(j, k) == 0)); --k)
  643.         ;                /* trim white space */
  644. #else /* NOT IBM_PC_MICROSOFT */
  645.     p = BITMAP(j, XBIT - 1);
  646.     for (k = XBIT - 1; ((k >= 0) && (*p == 0)); --k)
  647.         --p;            /* trim white space */
  648. #endif /* IBM_PC_MICROSOFT */
  649.  
  650.     }                    /* end loop over j */
  651.     ybottom = (j / 8) * 8 + 7;
  652.  
  653.     OUTF("\0333%c", 24);        /* 24/216 inch paperfeeding */
  654.  
  655.     for (j = ytop; (j >= ybottom); j -= 8)    /* loop over raster lines */
  656.     {                    /* in groups of 8 */
  657.  
  658. #if    SEGMEM
  659. #else /* NOT SEGMEM */
  660.     p = BITMAP(j, 0);        /* the j-th raster line */
  661. #endif /* SEGMEM */
  662.  
  663.     c = &v8[0];            /* vertical 8-bit encodings */
  664.     for (i = 0; i < XBIT; (++p, ++i))    /* loop over raster words */
  665.     {
  666.         /* PCC-20 compiled (1 << (HOST_WORD_SIZE-1)) to 0, so do it the
  667.         hard way, arghh... */
  668.         mask = 1;
  669.         mask <<= (HOST_WORD_SIZE - 1);    /* to select leftmost bit */
  670.  
  671. #if    SEGMEM
  672.         for (k = 0; k < 8; ++k)    /* compute pointers to 8 rasters */
  673.         q[k] = BITMAP(j - k, i);
  674. #endif /* SEGMEM */
  675.  
  676.         for (k = 0; k < HOST_WORD_SIZE; (++c, ++k))/* loop over word bits */
  677.         {
  678.         /* examine bits in 8 adjacent rows and build 8-bit */
  679.         /* character value */
  680.  
  681. #if    SEGMEM
  682.         *c = (BYTE) makechar(q, mask);
  683. #else /* NOT SEGMEM */
  684.         *c = (BYTE) makechar(&p, mask);
  685. #endif /* SEGMEM */
  686.  
  687.         mask >>= 1;        /* move masking bit right 1 position */
  688.         }                /* end loop over k */
  689.     }                /* end loop over i */
  690.     --c;                /* last character encoded */
  691.  
  692.     (void)outline((char *) &v8[0]);
  693.     }                    /* end loop over j */
  694.  
  695.     OUTS("\0332");            /* ESC 2 = normal paperfeeding */
  696.     OUTC('\f');                /* eject page with FF */
  697.  
  698.     (void)fflush(plotfp);
  699.     if (DISKFULL(plotfp))
  700.     (void)fatal("prtbmap(): Output error -- disk storage probably full");
  701. }
  702. #endif /* HIRES */
  703.  
  704. #include "prtpage.h"
  705. #include "readfont.h"
  706. #include "readgf.h"
  707. #include "readpk.h"
  708. #include "readpost.h"
  709. #include "readpxl.h"
  710. #include "reldfont.h"
  711. #include "rulepxl.h"
  712. #include "setchar.h"
  713. #include "setfntnm.h"
  714. #include "setrule.h"
  715. #include "signex.h"
  716. #include "skgfspec.h"
  717. #include "skipfont.h"
  718. #include "skpkspec.h"
  719. #include "special.h"
  720. #include "strchr.h"
  721. #include "strcm2.h"
  722. #include "strid2.h"
  723. #include "strrchr.h"
  724. #include "tctos.h"
  725. #include "usage.h"
  726. #include "warning.h"
  727.